package com.boot.notice;

import com.boot.constant.Constants;
import com.boot.utils.HttpRequestUtil;
import net.sf.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class AccessToken {

    public String getAccessToken(){
        Map<String, Object> params = new HashMap<>();
        params.put("grant_type", "client_credential");
        params.put("appid", Constants.wxAppId);
        params.put("secret", Constants.wxAppSecret);
        String result = HttpRequestUtil.sendPostMap(Constants.AccessTokenURL, params);
        JSONObject json = JSONObject.fromObject(result);
        // 获取密令（access_token）
        String access_token = json.get("access_token").toString();
        return access_token;
    }

}
